﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>Activacion de Usuario</title>
    <link rel="stylesheet" type="text/css" href="styles/ActivarUsuario.css" />
    <script type="text/javascript" src="Scripts/jquery/jquery-1.7.2.js"></script>
    <script type="text/javascript">
        function setCookie(c_name,value,exdays)
        {
            var exdate=new Date();
            exdate.setDate(exdate.getDate() + exdays);
            var c_value=escape(value) + ((exdays==null) ? "" : "; expires="+exdate.toUTCString());
            document.cookie=c_name + "=" + c_value;
        }
    </script>
</head>

<body>
<div id="divcentral">
   <p style="width: 1220px" >Bienvenido a elrTraking</p>
</div>
<div id="divinferior">
    <p>Tu cuenta  ha sido activada!!!</p>
    <p>&nbsp;</p>
    <p>Para comenzar a  utilizar elr-trackin haz click en la siguiente liga</p>
    <p>&nbsp;</p>
    <a href="http://localhost:1862/index.html#/u/home"><p>Inicio</p></a>
</div>
<script type="text/javascript">
    var Url = location.href;
    Url = Url.replace(/.*\?(.*?)/,"$1");
    Variables = Url.split ("&");
    for (i = 0; i < Variables.length; i++) {
        Separ = Variables[i].split("=");
        eval ('var '+Separ[0]+'="'+Separ[1]+'"');
    }
    console.log(id);
    $.ajax({
        url: "Services/User.svc/UpdateflagActivacion"
        ,type: "POST"
        ,dataType: "json"
        ,data: '{"codigo":"' + id + '"}'
        ,contentType: "application/json; charset=utf-8"
        ,success: function (data) {
            console.log('Usuario Activo');
        },
        error: function (result) {
            alert('Error al activar usuario ' + result.status + ' ' + result.statusText);
        }
    });
    $.ajax({
        url: "Services/User.svc/GetOneMail"
        ,type: "POST"
        ,dataType: "json"
        ,data: '{"codigo":"' + id + '"}'
        ,contentType: "application/json; charset=utf-8"
        ,success: function (data) {
            console.log(data.GetOneMailResult);
            var mail = data.GetOneMailResult;
            setCookie("username", mail, 30);
        },
        error: function (result) {
            alert('Error al recuperar datos  ' + result.status + ' ' + result.statusText);
        }
    });
</script>                
</body>
</html>
